/**
 * @file CmdGenerator.h
 * @author Huysmans Bjorn
 * @brief Declaration of the CmdGenerator class. This class will produce a list of
 *  which each item contains two numbers: angle in degrees and distance to be
 *  ridden in pixels
 */

#ifndef	CMDGENERATOR_H
#define CMDGENERATOR_H

#include "Point.h"
#include "Cmd.h"
#include <vector>

using namespace std;

/**
 * @brief CmdGenerator class generates commands for the robot
 */
class CmdGenerator{
	public:
		/** @brief Constructor */
		CmdGenerator();

		/** @brief Destructor */
		~CmdGenerator();

		/**
		 * @brief Generates a full list of commands
		 *
		 * @param	double CoordinatesList
		 *		List of all positions to go to in that order
		 *
		 * @param	int initialAngle
		 *		The initial angle of the robot
		 *
		 * @return list of commands with pairs of an turning angle(-180->180 degrees) and a
		 *         distance
		 */
		vector<Cmd> generateList(vector<Point> CoordinatesList, int initialAngle);

		/**
		 * @brief Calulates the amount of degrees the robot has to turn
		 *
		 * @param	int currentAngle
		 *		The current angle of the robot (horizontal reference)
		 *
		 *	@param	int	endAngle
		 *		The final angle the robot should point at
		 *
		 *	@return	the angle it has to actually turn
		 *		Left turn is negative angle
		 */
		int calculateTurn(int currentAngle, int endAngle);

		/**
		 * @brief Determines the quadrant of given angle
		 *
		 * @param int angle
		 *		The angle of which the quadrant has to be determined
		 *
		 *	@return the quadrant of the given angle
		 */
		int determineQuadrant(int angle);

		/** 
		 * @brief Calculates the angle
		 * 
		 * @param	Point p1
		 *		Point one
		 * @param	Point p2
		 *		Point two
		 * @param	int quadrant
		 *		The quadrant in which we are situated
		 * @return the angle in degrees between 0 and 360 on success, 
		 * 	   -1 on failure
		 */
		int calculateAngle(Point p1, Point p2, int quadrant);

		/**
		 * @brief Calculates the distance (Pythagoras)
		 *
		 * @param	Point p1
		 *		Point one
		 * @param	Point p2
		 *		Point two
		 * @return the distance between the two points in pixels on
		 *         success, -1 on failure.
		 */
		int calculateDistance(Point p1, Point p2);
};

#endif
